package com.qipay.admin.withdraw.controller;

import com.alibaba.fastjson.JSONObject;
import com.qipay.baas.model.Holiday;
import com.qipay.baas.model.Order;
import com.qipay.mapper.HolidayMapper;
import com.qipay.order.config.OrderStateEnum;
import com.qipay.order.service.OrderService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;

@RestController
@RequestMapping("/callback/v1/uspay")
public class UsPayDfCallbackController {
    protected final Logger logger = LoggerFactory.getLogger(getClass());
    @Autowired
    HolidayMapper holidayMapper;
    @Autowired
    OrderService orderService;

    @RequestMapping(value = "/quickin")
    private String UspayCallback(
            HttpServletRequest request,
            @RequestBody JSONObject jsonObject
            ) throws Exception {
        logger.info("request from " + request.getRequestURI() + ", request body:" + jsonObject.toString());
        String tradeNo = jsonObject.getString("orderNo");
        //--------插入日志
        Holiday reqLog = new Holiday();
        reqLog.setDate(tradeNo);//请求报文
        reqLog.setIsHoliday((byte)2);//请求类型，1表示查询,2表示代付
        reqLog.setName(jsonObject.toString());//响应报文
        holidayMapper.insert(reqLog);
        //---------日志结束
        return "success";
    }
}
